package com.ikun.lease.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(Minioproperties.class)
@ConditionalOnProperty(name = "minio.endpoint")
public class MinioConfiguration {
    @Autowired
    private Minioproperties minioproperties;

    @Bean
    public MinioClient minioClient(){
        return MinioClient.builder().endpoint(minioproperties.getEndpoint()).credentials(minioproperties.getAccessKey(),minioproperties.getSecretKey()).build();
    }
}
